﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SLIP.Core;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Prism.Logging;
using Microsoft.Practices.Prism.Events;

namespace ExampleModules.ViewModels
{
    public class ExampleViewModel : SLIPViewModelBase, IExampleViewModel
    {
        private DelegateCommand _testCmd;
        private string _stringData;

        public string StringData
        {
            get
            {
                return _stringData;
            }
            set
            {
                _stringData = value;
                RaisePropertyChanged("StringData");
            }
        }

        public ICommand TestCmd
        {
            get
            {
                return _testCmd;
            }
        }

        //TODO encapsulate this so it is always available in the base class and developer can just use default const for 
        // vm class
        public ExampleViewModel(IRegionManager pManager, ILoggerFacade pLogger, IEventAggregator pAggregator)
            : base(pManager, pLogger, pAggregator) 
        {
            _testCmd = new DelegateCommand(DoTestCmd, () => true);
            StringData = "...";

            //_logger.Log("Error msg", Category.Exception, Priority.High);
        }

        private void DoTestCmd()
        {
            //Next two lines for test event
            //var anEvent = _aggregator.GetEvent<TestEvent>();
            //anEvent.Publish(true);

            //Next lines for SLIPBaseEvent example
            string EventKey = "TEST";
            string EventData = "*** Data ***";
            SLIPBaseEvent anEvent = _aggregator.GetEvent<SLIPBaseEvent>();
            anEvent.Publish(new BaseEvent(EventKey, EventData));

            //MessageBox.Show("Event Published.");
        }
    }
}
